package com.hivision.controller.Energy;

import cn.hutool.core.util.ObjectUtil;
import com.hivision.alimqttapi.entity.TechnicalAttribute;
import com.hivision.iot.api.AliReqClient;
import com.hivision.iot.dto.AttributeValueRequestDTO;
import com.hivision.mapper.TechnicalAttributeMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.List;
import java.util.Random;

/**
 * @author kzyang
 * @version 1.0
 * @date 2024-08-15 11:50
 */
@RequestMapping("/energyWritePlc")
@RestController
@Slf4j
public class EnergyWritePlc {

    @Autowired
    private AliReqClient reqClient;
    @Autowired
    TechnicalAttributeMapper technicalAttributeMapper;

    List<String> list = Arrays.asList("DN_RO1_water1",
            "DN_RO1_water2",
            "DN_RO1_water3",
            "DN_RO1_water4",
            "DN_RO1_water5",
            "DN_RO1_water6",
            "DN_RO1_water7",
            "DN_RO1_water8",
            "DN_RO1_water9",
            "DN_RO1_water10",
            "DN_RO1_water11",
            "DN_RO1_water12",
            "DN_RO1_water13",
            "DN_RO1_water14",
            "DN_RO1_water15",
            "DN_RO1_water16",
            "DN_RO1_water17",
            "DN_RO1_water18",
            "DN_RO1_water19",
            "DN_RO1_water20",
            "DN_RO1_water21",
            "DN_RO1_water22",
            "DN_RO1_water23",
            "DN_RO1_water24",
            "DN_RO1_water25",
            "DN_RO1_water26");
    List<String> waterRo2 = Arrays.asList("DN_RO2_water1",
            "DN_RO2_water2",
            "DN_RO2_water3");

    List<String> electricityList = Arrays.asList("DN_electricity1", "DN_electricity2", "DN_electricity3", "DN_electricity4",
            "DN_electricity5", "DN_electricity6", "DN_electricity7", "DN_electricity8", "DN_electricity9", "DN_electricity10",
            "DN_electricity11", "DN_electricity12", "DN_electricity13", "DN_electricity14", "DN_electricity15", "DN_electricity16",
            "DN_electricity17", "DN_electricity18", "DN_electricity19", "DN_electricity20", "DN_electricity21", "DN_electricity22", "DN_electricity23", "DN_electricity24",
            "DN_electricity25", "DN_electricity26", "DN_electricity27", "DN_electricity28", "DN_electricity29", "DN_electricity30", "DN_electricity31",
            "DN_electricity32", "DN_electricity33", "DN_electricity34", "DN_electricity35", "DN_electricity36", "DN_electricity37", "DN_electricity38", "DN_electricity39", "DN_electricity40", "DN_electricity41",
            "DN_electricity42", "DN_electricity43", "DN_electricity44", "DN_electricity45", "DN_electricity46", "DN_electricity47", "DN_electricity48",
            "DN_electricity49", "DN_electricity50", "DN_electricity51", "DN_electricity52", "DN_electricity53", "DN_electricity54",
            "DN_electricity55", "DN_electricity56", "DN_electricity57", "DN_electricity58", "DN_electricity59", "DN_electricity60",
            "DN_electricity61", "DN_electricity62", "DN_electricity63", "DN_electricity64", "DN_electricity65", "DN_electricity66", "DN_electricity67", "DN_electricity68",
            "DN_electricity69", "DN_electricity70", "DN_electricity71", "DN_electricity72", "DN_electricity73", "DN_electricity74", "DN_electricity75", "DN_electricity76",
            "DN_electricity77", "DN_electricity78", "DN_electricity79", "DN_electricity80", "DN_electricity81", "DN_electricity82",
            "DN_electricity83", "DN_electricity84", "DN_electricity85", "DN_electricity86", "DN_electricity87", "DN_electricity88",
            "DN_electricity89", "DN_electricity90", "DN_electricity91", "DN_electricity92", "DN_electricity93", "DN_electricity94",
            "DN_electricity95", "DN_electricity96", "DN_electricity97", "DN_electricity98", "DN_electricity99", "DN_electricity100", "DN_electricity101", "DN_electricity102", "DN_electricity103",
            "DN_electricity104", "DN_electricity105", "DN_electricity106", "DN_electricity107", "DN_electricity108", "DN_electricity109", "DN_electricity110", "DN_electricity111",
            "DN_electricity112", "DN_electricity113", "DN_electricity114", "DN_electricity115", "DN_electricity116", "DN_electricity117", "DN_electricity118",
            "DN_electricity119", "DN_electricity120", "DN_electricity121", "DN_electricity122", "DN_electricity123", "DN_electricity124",
            "DN_electricity125", "DN_electricity126", "DN_electricity127");

    List<String> wasteWaterList = Arrays.asList("DN_wasteWater1", "DN_wasteWater2", "DN_wasteWater3", "DN_wasteWater4", "DN_wasteWater5", "DN_wasteWater6", "DN_wasteWater7", "DN_wasteWater8", "DN_wasteWater9");

    List<String> industrialWaterList = Arrays.asList("DN_industrialWater1", "DN_industrialWater1", "DN_industrialWater2",
            "DN_industrialWater2", "DN_industrialWater3", "DN_industrialWater3", "DN_industrialWater4", "DN_industrialWater4",
            "DN_industrialWater5", "DN_industrialWater5", "DN_industrialWater6", "DN_industrialWater6");


    List<String> chilledWater = Arrays.asList("DN_chilledWater1", "DN_chilledWater2", "DN_chilledWater3", "DN_chilledWater4", "DN_chilledWater5", "DN_chilledWater6", "DN_chilledWater7", "DN_chilledWater8",
            "DN_chilledWater9", "DN_chilledWater10", "DN_chilledWater11", "DN_chilledWater12", "DN_chilledWater13", "DN_chilledWater14", "DN_chilledWater15", "DN_chilledWater16", "DN_chilledWater17",
            "DN_chilledWater18", "DN_chilledWater19", "DN_chilledWater20", "DN_chilledWater21", "DN_chilledWater22", "DN_chilledWater23", "DN_chilledWater24", "DN_chilledWater25",
            "DN_chilledWater26", "DN_chilledWater27", "DN_chilledWater28");

    List<String> hotWater = Arrays.asList("DN_hotWater1", "DN_hotWater2", "DN_hotWater3", "DN_hotWater4",
            "DN_hotWater5", "DN_hotWater6", "DN_hotWater7", "DN_hotWater8");
    @Scheduled(cron="0 */1 * * * ?")
    @GetMapping("writeWaterRO1")
    public void writeWaterRO1(){
        for (String s : list) {
            // 创建 Random 类的一个实例
            Random random = new Random();
            // 生成一个0到10之间的随机整数
            int randomNumber = random.nextInt(11);

            // 获取当前系统的日期时间，考虑到时区
            ZonedDateTime now = ZonedDateTime.now(ZoneId.of("Asia/Shanghai"));
            // 创建一个日期时间格式器，匹配所需的格式
            DateTimeFormatter formatter = DateTimeFormatter.ISO_ZONED_DATE_TIME;
            // 格式化当前日期时间为字符串
            String formattedNow = now.format(formatter);
            TechnicalAttribute technicalAttribute1 = new TechnicalAttribute();
            technicalAttribute1.setAttributeGroupName(s);
            technicalAttribute1.setAttributeCode("DN_RO_TF");
            BigDecimal bigDecimal = technicalAttributeMapper.selectTechnicalAttributeList(technicalAttribute1);
            if (ObjectUtil.isNull(bigDecimal)){
                bigDecimal = new BigDecimal("0.0");
            }
            BigDecimal randomFloat = bigDecimal.add(new BigDecimal("0.1"));
            AttributeValueRequestDTO attributeValueRequestDTO = new AttributeValueRequestDTO();
            attributeValueRequestDTO.setAssetCode(s);
            attributeValueRequestDTO.setAttributeCode("DN_RO_TF");
            attributeValueRequestDTO.setValue(String.valueOf(randomFloat));
            reqClient.patchAttributeValue(attributeValueRequestDTO);
            TechnicalAttribute technicalAttribute=new TechnicalAttribute();
            technicalAttribute.setWritable("t");
            technicalAttribute.setMeasureUni("无");
            technicalAttribute.setMinValue("min无");
            technicalAttribute.setMaxValueNew("max无");
            technicalAttribute.setAssetCode(s);
            technicalAttribute.setAttributeName("累计流量");
            technicalAttribute.setDataTypeNew("Double");
            technicalAttribute.setAttributeGroupName(s);
            technicalAttribute.setAttributeCode("DN_RO_TF");
            technicalAttribute.setAttributeDescs("无");
            technicalAttribute.setAttributeGroupDescs("无");
            technicalAttribute.setEnumValue(String.valueOf(randomFloat));

            technicalAttribute.setPrecisionNew(36L);
            technicalAttribute.setCreatedAt(formattedNow);
            technicalAttribute.setModifiedAt(formattedNow);
            technicalAttributeMapper.insertTechnicalAttribute(technicalAttribute);
        }
    }

    @Scheduled(cron="0 */1 * * * ?")
    @GetMapping("writeWaterRO2")
    public void writeWaterRO2(){
        for (String s : waterRo2) {

            // 创建 Random 类的一个实例
            Random random = new Random();
            // 生成一个0到10之间的随机整数
            int randomNumber = random.nextInt(11);

            // 获取当前系统的日期时间，考虑到时区
            ZonedDateTime now = ZonedDateTime.now(ZoneId.of("Asia/Shanghai"));
            // 创建一个日期时间格式器，匹配所需的格式
            DateTimeFormatter formatter = DateTimeFormatter.ISO_ZONED_DATE_TIME;
            // 格式化当前日期时间为字符串
            String formattedNow = now.format(formatter);
            TechnicalAttribute technicalAttribute1 = new TechnicalAttribute();
            technicalAttribute1.setAttributeGroupName(s);
            technicalAttribute1.setAttributeCode("DN_RO_TF");
            BigDecimal bigDecimal = technicalAttributeMapper.selectTechnicalAttributeList(technicalAttribute1);
            if (ObjectUtil.isNull(bigDecimal)){
                bigDecimal = new BigDecimal("0.0");
            }
            BigDecimal randomFloat = bigDecimal.add(new BigDecimal("0.1"));
            AttributeValueRequestDTO attributeValueRequestDTO = new AttributeValueRequestDTO();
            attributeValueRequestDTO.setAssetCode(s);
            attributeValueRequestDTO.setAttributeCode("DN_RO_TF");
            attributeValueRequestDTO.setValue(String.valueOf(randomFloat));
            reqClient.patchAttributeValue(attributeValueRequestDTO);
            TechnicalAttribute technicalAttribute=new TechnicalAttribute();
            technicalAttribute.setWritable("t");
            technicalAttribute.setMeasureUni("无");
            technicalAttribute.setMinValue("min无");
            technicalAttribute.setMaxValueNew("max无");
            technicalAttribute.setAssetCode(s);
            technicalAttribute.setAttributeName("累计流量");
            technicalAttribute.setDataTypeNew("Double");
            technicalAttribute.setAttributeGroupName(s);
            technicalAttribute.setAttributeCode("DN_RO_TF");
            technicalAttribute.setAttributeDescs("无");
            technicalAttribute.setAttributeGroupDescs("无");
            technicalAttribute.setEnumValue(String.valueOf(randomFloat));
            technicalAttribute.setPrecisionNew(36L);
            technicalAttribute.setCreatedAt(formattedNow);
            technicalAttribute.setModifiedAt(formattedNow);
            technicalAttributeMapper.insertTechnicalAttribute(technicalAttribute);
        }
    }

    @Scheduled(cron="0 */1 * * * ?")
    @GetMapping("electricity")
    public void electricity(){
        for (String s : electricityList) {
            // 获取当前系统的日期时间，考虑到时区
            ZonedDateTime now = ZonedDateTime.now(ZoneId.of("Asia/Shanghai"));
            // 创建一个日期时间格式器，匹配所需的格式
            DateTimeFormatter formatter = DateTimeFormatter.ISO_ZONED_DATE_TIME;
            // 格式化当前日期时间为字符串
            String formattedNow = now.format(formatter);
            TechnicalAttribute technicalAttribute1 = new TechnicalAttribute();
            technicalAttribute1.setAttributeGroupName(s);
            technicalAttribute1.setAttributeCode("DN_electric_Ep");
            BigDecimal bigDecimal = technicalAttributeMapper.selectTechnicalAttributeList(technicalAttribute1);
            if (ObjectUtil.isNull(bigDecimal)){
                bigDecimal = new BigDecimal("0.0");
            }
            BigDecimal randomFloat = bigDecimal.add(new BigDecimal("0.1"));
            AttributeValueRequestDTO attributeValueRequestDTO = new AttributeValueRequestDTO();
            attributeValueRequestDTO.setAssetCode(s);
            attributeValueRequestDTO.setAttributeCode("DN_electric_Ep");
            attributeValueRequestDTO.setValue(String.valueOf(randomFloat));
            reqClient.patchAttributeValue(attributeValueRequestDTO);
            TechnicalAttribute technicalAttribute=new TechnicalAttribute();
            technicalAttribute.setWritable("t");
            technicalAttribute.setMeasureUni("无");
            technicalAttribute.setMinValue("min无");
            technicalAttribute.setMaxValueNew("max无");
            technicalAttribute.setAssetCode(s);
            technicalAttribute.setAttributeName("有功电能");
            technicalAttribute.setDataTypeNew("Double");
            technicalAttribute.setAttributeGroupName(s);
            technicalAttribute.setAttributeCode("DN_electric_Ep");
            technicalAttribute.setAttributeDescs("无");
            technicalAttribute.setAttributeGroupDescs("无");
            technicalAttribute.setEnumValue(String.valueOf(randomFloat));
            technicalAttribute.setPrecisionNew(36L);
            technicalAttribute.setCreatedAt(formattedNow);
            technicalAttribute.setModifiedAt(formattedNow);
            technicalAttributeMapper.insertTechnicalAttribute(technicalAttribute);
        }
    }

    @Scheduled(cron="0 */1 * * * ?")
    @GetMapping("wasteWater")
    public void wasteWater(){
        for (String s : wasteWaterList) {

            // 创建 Random 类的一个实例
            Random random = new Random();
            // 生成一个0到10之间的随机整数
            int randomNumber = random.nextInt(11);

            // 获取当前系统的日期时间，考虑到时区
            ZonedDateTime now = ZonedDateTime.now(ZoneId.of("Asia/Shanghai"));
            // 创建一个日期时间格式器，匹配所需的格式
            DateTimeFormatter formatter = DateTimeFormatter.ISO_ZONED_DATE_TIME;
            // 格式化当前日期时间为字符串
            String formattedNow = now.format(formatter);
            TechnicalAttribute technicalAttribute1 = new TechnicalAttribute();
            technicalAttribute1.setAttributeGroupName(s);
            technicalAttribute1.setAttributeCode("DN_RO_TF");
            BigDecimal bigDecimal = technicalAttributeMapper.selectTechnicalAttributeList(technicalAttribute1);
            if (ObjectUtil.isNull(bigDecimal)){
                bigDecimal = new BigDecimal("0.0");
            }
            BigDecimal randomFloat = bigDecimal.add(new BigDecimal("0.1"));
            AttributeValueRequestDTO attributeValueRequestDTO = new AttributeValueRequestDTO();
            attributeValueRequestDTO.setAssetCode(s);
            attributeValueRequestDTO.setAttributeCode("DN_RO_TF");
            attributeValueRequestDTO.setValue(String.valueOf(randomFloat));
            reqClient.patchAttributeValue(attributeValueRequestDTO);
            TechnicalAttribute technicalAttribute=new TechnicalAttribute();
            technicalAttribute.setWritable("t");
            technicalAttribute.setMeasureUni("无");
            technicalAttribute.setMinValue("min无");
            technicalAttribute.setMaxValueNew("max无");
            technicalAttribute.setAssetCode(s);
            technicalAttribute.setAttributeName("累计流量");
            technicalAttribute.setDataTypeNew("Double");
            technicalAttribute.setAttributeGroupName(s);
            technicalAttribute.setAttributeCode("DN_RO_TF");
            technicalAttribute.setAttributeDescs("无");
            technicalAttribute.setAttributeGroupDescs("无");
            technicalAttribute.setEnumValue(String.valueOf(randomFloat));
            technicalAttribute.setPrecisionNew(36L);
            technicalAttribute.setCreatedAt(formattedNow);
            technicalAttribute.setModifiedAt(formattedNow);
            technicalAttributeMapper.insertTechnicalAttribute(technicalAttribute);
        }
    }
    @Scheduled(cron="0 */1 * * * ?")
    @GetMapping("industrialWater")
    public void industrialWater(){
        for (String s : industrialWaterList) {

            // 创建 Random 类的一个实例
            Random random = new Random();
            // 生成一个0到10之间的随机整数
            int randomNumber = random.nextInt(11);

            // 获取当前系统的日期时间，考虑到时区
            ZonedDateTime now = ZonedDateTime.now(ZoneId.of("Asia/Shanghai"));
            // 创建一个日期时间格式器，匹配所需的格式
            DateTimeFormatter formatter = DateTimeFormatter.ISO_ZONED_DATE_TIME;
            // 格式化当前日期时间为字符串
            String formattedNow = now.format(formatter);
            TechnicalAttribute technicalAttribute1 = new TechnicalAttribute();
            technicalAttribute1.setAttributeGroupName(s);
            technicalAttribute1.setAttributeCode("DN_CW_TF_D");
            BigDecimal bigDecimal = technicalAttributeMapper.selectTechnicalAttributeList(technicalAttribute1);
            if (ObjectUtil.isNull(bigDecimal)){
                bigDecimal = new BigDecimal("0.0");
            }
            BigDecimal randomFloat = bigDecimal.add(new BigDecimal("0.1"));
            AttributeValueRequestDTO attributeValueRequestDTO = new AttributeValueRequestDTO();
            attributeValueRequestDTO.setAssetCode(s);
            attributeValueRequestDTO.setAttributeCode("DN_CW_TF_D");
            attributeValueRequestDTO.setValue(String.valueOf(randomFloat));
            reqClient.patchAttributeValue(attributeValueRequestDTO);
            TechnicalAttribute technicalAttribute=new TechnicalAttribute();
            technicalAttribute.setWritable("t");
            technicalAttribute.setMeasureUni("无");
            technicalAttribute.setMinValue("min无");
            technicalAttribute.setMaxValueNew("max无");
            technicalAttribute.setAssetCode(s);
            technicalAttribute.setAttributeName("累计流量小数部分");
            technicalAttribute.setDataTypeNew("Double");
            technicalAttribute.setAttributeGroupName(s);
            technicalAttribute.setAttributeCode("DN_CW_TF_D");
            technicalAttribute.setAttributeDescs("无");
            technicalAttribute.setAttributeGroupDescs("无");
            technicalAttribute.setEnumValue(String.valueOf(randomFloat));
            technicalAttribute.setPrecisionNew(36L);
            technicalAttribute.setCreatedAt(formattedNow);
            technicalAttribute.setModifiedAt(formattedNow);
            technicalAttributeMapper.insertTechnicalAttribute(technicalAttribute);
            attributeValueRequestDTO.setAttributeCode("DN_CW_TF");
            technicalAttribute1.setAttributeCode("DN_CW_TF");
            bigDecimal = technicalAttributeMapper.selectTechnicalAttributeList(technicalAttribute1);
            if (ObjectUtil.isNull(bigDecimal)){
                bigDecimal = new BigDecimal("0.0");
            }
            randomFloat = bigDecimal.add(new BigDecimal("0.1"));
            attributeValueRequestDTO.setValue(String.valueOf(randomFloat));
            reqClient.patchAttributeValue(attributeValueRequestDTO);
            technicalAttribute.setAttributeCode("DN_CW_TF");
            technicalAttribute.setAttributeName("累计流量");
            technicalAttribute.setEnumValue(String.valueOf(randomFloat));
            technicalAttributeMapper.insertTechnicalAttribute(technicalAttribute);
        }
    }
    @Scheduled(cron="0 */1 * * * ?")
    @GetMapping("chilledWater")
    public void chilledWater(){
        for (String s : chilledWater) {

            // 创建 Random 类的一个实例
            Random random = new Random();

            // 获取当前系统的日期时间，考虑到时区
            ZonedDateTime now = ZonedDateTime.now(ZoneId.of("Asia/Shanghai"));
            // 创建一个日期时间格式器，匹配所需的格式
            DateTimeFormatter formatter = DateTimeFormatter.ISO_ZONED_DATE_TIME;
            // 格式化当前日期时间为字符串
            String formattedNow = now.format(formatter);
            TechnicalAttribute technicalAttribute1 = new TechnicalAttribute();
            technicalAttribute1.setAttributeGroupName(s);
            technicalAttribute1.setAttributeCode("DN_CW_TQ");
            BigDecimal bigDecimal = technicalAttributeMapper.selectTechnicalAttributeList(technicalAttribute1);
            if (ObjectUtil.isNull(bigDecimal)){
                bigDecimal = new BigDecimal("0.0");
            }
            BigDecimal randomFloat = bigDecimal.add(new BigDecimal("0.1"));
            AttributeValueRequestDTO attributeValueRequestDTO = new AttributeValueRequestDTO();
            attributeValueRequestDTO.setAssetCode(s);
            attributeValueRequestDTO.setAttributeCode("DN_CW_TQ");
            attributeValueRequestDTO.setValue(String.valueOf(randomFloat));
            reqClient.patchAttributeValue(attributeValueRequestDTO);
            TechnicalAttribute technicalAttribute=new TechnicalAttribute();
            technicalAttribute.setWritable("t");
            technicalAttribute.setMeasureUni("无");
            technicalAttribute.setMinValue("min无");
            technicalAttribute.setMaxValueNew("max无");
            technicalAttribute.setAssetCode(s);
            technicalAttribute.setAttributeName("累计冷量");
            technicalAttribute.setDataTypeNew("Double");
            technicalAttribute.setAttributeGroupName(s);
            technicalAttribute.setAttributeCode("DN_CW_TQ");
            technicalAttribute.setAttributeDescs("无");
            technicalAttribute.setAttributeGroupDescs("无");
            technicalAttribute.setEnumValue(String.valueOf(randomFloat));
            technicalAttribute.setPrecisionNew(36L);
            technicalAttribute.setCreatedAt(formattedNow);
            technicalAttribute.setModifiedAt(formattedNow);
            technicalAttributeMapper.insertTechnicalAttribute(technicalAttribute);
        }
    }
    @Scheduled(cron="0 */1 * * * ?")
    @GetMapping("hotWater")
    public void hotWater(){
        for (String s : hotWater) {
            // 创建 Random 类的一个实例
            Random random = new Random();
            // 生成一个0到10之间的随机整数
            int randomNumber = random.nextInt(11);

            // 获取当前系统的日期时间，考虑到时区
            ZonedDateTime now = ZonedDateTime.now(ZoneId.of("Asia/Shanghai"));
            // 创建一个日期时间格式器，匹配所需的格式
            DateTimeFormatter formatter = DateTimeFormatter.ISO_ZONED_DATE_TIME;
            // 格式化当前日期时间为字符串
            String formattedNow = now.format(formatter);
            TechnicalAttribute technicalAttribute1 = new TechnicalAttribute();
            technicalAttribute1.setAttributeGroupName(s);
            technicalAttribute1.setAttributeCode("DN_HW_TQ");
            BigDecimal bigDecimal = technicalAttributeMapper.selectTechnicalAttributeList(technicalAttribute1);
            if (ObjectUtil.isNull(bigDecimal)){
                bigDecimal = new BigDecimal("0.00000");
            }
            BigDecimal randomFloat = bigDecimal.add(new BigDecimal("0.1"));
            AttributeValueRequestDTO attributeValueRequestDTO = new AttributeValueRequestDTO();
            attributeValueRequestDTO.setAssetCode(s);
            attributeValueRequestDTO.setAttributeCode("DN_HW_TQ");
            attributeValueRequestDTO.setValue(String.valueOf(randomFloat).substring(0, 4));
            System.out.println("ssss"+attributeValueRequestDTO);
            reqClient.patchAttributeValue(attributeValueRequestDTO);
            TechnicalAttribute technicalAttribute=new TechnicalAttribute();
            technicalAttribute.setWritable("t");
            technicalAttribute.setMeasureUni("无");
            technicalAttribute.setMinValue("min无");
            technicalAttribute.setMaxValueNew("max无");
            technicalAttribute.setAssetCode(s);
            technicalAttribute.setAttributeName("累计热量");
            technicalAttribute.setDataTypeNew("Double");
            technicalAttribute.setAttributeGroupName(s);
            technicalAttribute.setAttributeCode("DN_HW_TQ");
            technicalAttribute.setAttributeDescs("无");
            technicalAttribute.setAttributeGroupDescs("无");
            technicalAttribute.setEnumValue(String.valueOf(randomFloat));
            technicalAttribute.setPrecisionNew(36L);
            technicalAttribute.setCreatedAt(formattedNow);
            technicalAttribute.setModifiedAt(formattedNow);
            technicalAttributeMapper.insertTechnicalAttribute(technicalAttribute);
        }
    }
    @Scheduled(cron="0 */1 * * * ?")
    @GetMapping("naturalGas")
    public void naturalGas(){
        for (int i = 1; i < 61; i++) {
            String s = "DN_naturalGas"+i;
            // 创建 Random 类的一个实例
            Random random = new Random();
            // 生成一个0到10之间的随机整数
            int randomNumber = random.nextInt(11);

            // 获取当前系统的日期时间，考虑到时区
            ZonedDateTime now = ZonedDateTime.now(ZoneId.of("Asia/Shanghai"));
            // 创建一个日期时间格式器，匹配所需的格式
            DateTimeFormatter formatter = DateTimeFormatter.ISO_ZONED_DATE_TIME;
            // 格式化当前日期时间为字符串
            String formattedNow = now.format(formatter);
            TechnicalAttribute technicalAttribute1 = new TechnicalAttribute();
            technicalAttribute1.setAttributeGroupName(s);
            technicalAttribute1.setAttributeCode("DN_TotalFlow");
            BigDecimal bigDecimal = technicalAttributeMapper.selectTechnicalAttributeList(technicalAttribute1);
            if (ObjectUtil.isNull(bigDecimal)){
                bigDecimal = new BigDecimal("0.0");
            }
            BigDecimal randomFloat = bigDecimal.add(new BigDecimal("0.1"));
            AttributeValueRequestDTO attributeValueRequestDTO = new AttributeValueRequestDTO();
            attributeValueRequestDTO.setAssetCode(s);
            attributeValueRequestDTO.setAttributeCode("DN_TotalFlow");
            attributeValueRequestDTO.setValue(String.valueOf(randomFloat));
            reqClient.patchAttributeValue(attributeValueRequestDTO);
            TechnicalAttribute technicalAttribute=new TechnicalAttribute();
            technicalAttribute.setWritable("t");
            technicalAttribute.setMeasureUni("无");
            technicalAttribute.setMinValue("min无");
            technicalAttribute.setMaxValueNew("max无");
            technicalAttribute.setAssetCode(s);
            technicalAttribute.setAttributeName("累计流量");
            technicalAttribute.setDataTypeNew("Double");
            technicalAttribute.setAttributeGroupName(s);
            technicalAttribute.setAttributeCode("DN_TotalFlow");
            technicalAttribute.setAttributeDescs("无");
            technicalAttribute.setAttributeGroupDescs("无");
            technicalAttribute.setEnumValue(String.valueOf(randomFloat));
            technicalAttribute.setPrecisionNew(36L);
            technicalAttribute.setCreatedAt(formattedNow);
            technicalAttribute.setModifiedAt(formattedNow);
            technicalAttributeMapper.insertTechnicalAttribute(technicalAttribute);
        }
    }
    @Scheduled(cron="0 */1 * * * ?")
    @GetMapping("pressurizedAir")
    public void pressurizedAir(){
        for (int i = 1; i < 22; i++) {
            String s = "DN_pressurizedAir"+i;
            // 创建 Random 类的一个实例
            Random random = new Random();
            // 生成一个0到10之间的随机整数
            int randomNumber = random.nextInt(11);

            // 获取当前系统的日期时间，考虑到时区
            ZonedDateTime now = ZonedDateTime.now(ZoneId.of("Asia/Shanghai"));
            // 创建一个日期时间格式器，匹配所需的格式
            DateTimeFormatter formatter = DateTimeFormatter.ISO_ZONED_DATE_TIME;
            // 格式化当前日期时间为字符串
            String formattedNow = now.format(formatter);
            TechnicalAttribute technicalAttribute1 = new TechnicalAttribute();
            technicalAttribute1.setAttributeGroupName(s);
            technicalAttribute1.setAttributeCode("DN_TotalConutOfAir");
            BigDecimal bigDecimal = technicalAttributeMapper.selectTechnicalAttributeList(technicalAttribute1);
            if (ObjectUtil.isNull(bigDecimal)){
                bigDecimal = new BigDecimal("0.0");
            }
            BigDecimal randomFloat = bigDecimal.add(new BigDecimal("0.1"));
            AttributeValueRequestDTO attributeValueRequestDTO = new AttributeValueRequestDTO();
            attributeValueRequestDTO.setAssetCode(s);
            attributeValueRequestDTO.setAttributeCode("DN_TotalConutOfAir");
            attributeValueRequestDTO.setValue(String.valueOf(randomFloat));
            reqClient.patchAttributeValue(attributeValueRequestDTO);
            TechnicalAttribute technicalAttribute = new TechnicalAttribute();
            technicalAttribute.setWritable("t");
            technicalAttribute.setMeasureUni("无");
            technicalAttribute.setMinValue("min无");
            technicalAttribute.setMaxValueNew("max无");
            technicalAttribute.setAssetCode(s);
            technicalAttribute.setAttributeName("总流量");
            technicalAttribute.setDataTypeNew("Double");
            technicalAttribute.setAttributeGroupName(s);
            technicalAttribute.setAttributeCode("DN_TotalConutOfAir");
            technicalAttribute.setAttributeDescs("无");
            technicalAttribute.setAttributeGroupDescs("无");
            technicalAttribute.setEnumValue(String.valueOf(randomFloat));
            technicalAttribute.setPrecisionNew(36L);
            technicalAttribute.setCreatedAt(formattedNow);
            technicalAttribute.setModifiedAt(formattedNow);
            technicalAttributeMapper.insertTechnicalAttribute(technicalAttribute);
        }
    }

}
